import ajax from "../modules/ajax.js"
import {$,$$} from "../modules/public.js"

export default function(proID,data){
  ajax({
    url:"http://localhost:3000/cartupdata",
    method:"post",
    data:{
      num:$(".num input").value,
      proID
    }
  }).then(res=>{
    data.forEach((val,index)=>{
      if(val.proID===Number(proID)){
        data[index].num=$(".num input").value-0
        $(".sum").innerHTML=$(".num input").value*data[index].price
        sessionStorage.setItem("data",JSON.stringify(data))
      }
    })
    console.log(res);
  })
}